<?php

namespace App\Services\Draw\PoolGroupObject;


use App\Exceptions\BasicException;
use App\Repositories\GiftRepository;
use App\Services\Draw\DrawConst\CacheKey;
use App\Services\Draw\DrawFactory;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

/**
 * 扭蛋抽奖实体
 * @author wrh
 */
class PoolGroup
{
    public $id;
    public $pool_id;
    public $tag;
    public $name;
    public $round;
    public $count;
    public $current_group_id;
    public $top_count;
    public $top_random;
    public $big_count;
    public $big_random;
    public $top_step_section;
    public $big_step_section;
    public $lucky_input_value_date;
    public $prop_count;
    public $prop_random;
    public $prop_step_section;
    public $prop_count_section;
    public $group_id;
    public $poolModel;
    public $poolGroupModel;
    public $poolPrizeModel;
    public $poolTemplateModel;
    public $cachePrefix = '';
    public $privateKey = '';
    protected $redisObject;
    public $addPoolRepo;
    public $checkRecordModel;
    public $addPoolAccountRecordModel;
    public $gameLockTime;//游戏轮次更替锁定时间

    public function __construct($redisObject)
    {
        $this->redisObject = $redisObject;
    }

    /**
     * @return mixed
     */
    public function getPropCount()
    {
        return $this->prop_count;
    }

    /**
     * @param mixed $prop_count
     */
    public function setPropCount($prop_count): void
    {
        $this->prop_count = $prop_count;
    }

    /**
     * @return mixed
     */
    public function getPropRandom()
    {
        return $this->prop_random;
    }

    /**
     * @param mixed $prop_random
     */
    public function setPropRandom($prop_random): void
    {
        $this->prop_random = $prop_random;
    }

    /**
     * @return mixed
     */
    public function getPropStepSection()
    {
        return $this->prop_step_section;
    }

    /**
     * @param mixed $prop_step_section
     */
    public function setPropStepSection($prop_step_section): void
    {
        $this->prop_step_section = $prop_step_section;
    }

    /**
     * @return mixed
     */
    public function getPropCountSection()
    {
        return $this->prop_count_section;
    }

    /**
     * @param mixed $prop_count_section
     */
    public function setPropCountSection($prop_count_section): void
    {
        $this->prop_count_section = $prop_count_section;
    }

    public function updateExtraData()
    {
        return true;
    }

    public function getNewPoolGroup()
    {
    }

    /**
     * 公池组随机规则
     * @param $poolGroupList
     * @return Collection|mixed
     */
    public function randomGroup($poolGroupList)
    {
        return $poolGroupList->random();
    }

    public function decPoolPrize(array $drawPrizes)
    {
        return $this->poolPrizeModel->batchDecPrizesByGroup($this, $drawPrizes);
    }

    /**
     * 检查本期礼物是否充足
     * @param Collection $poolPrizeList
     * @param int $drawCount
     * @param $user
     * @param Collection $poolConfig
     * @return bool
     */
    public function checkDrawRoundPrizeCount(Collection $poolPrizeList, int $drawCount, $user, $poolConfig)
    {
        if ($poolPrizeList->isEmpty()) {
            return false;
        }
        $smallPrizeCount = $poolPrizeList->where('count', '>', 0)->where('price', '<', $poolConfig->big_gift_coin)->sum('count');
        if ($drawCount > $smallPrizeCount) { // 奖池的剩余礼物不足抽取次数
            return false;
        }

        return true;
    }

    public function getPoolPrizeList($user)
    {
        //先通过group查询prize表获取 礼物模板ID  再通过模板ID查询礼物
        $poolPrizeList = $this->poolPrizeModel->getPrizeListWithGift(['pool_id' => $this->pool_id], ['gift_template_id', 'count',
            'group_id', 'template_count', 'gift_id']);
        $giftIds       = $poolPrizeList->pluck('gift_id');
        $gifts         = (new GiftRepository())->giftsByIdsWithField($giftIds, ['id', 'price']); // 抽中礼物信息
        $giftsWithId   = $gifts->keyBy('id');
        foreach ($poolPrizeList as &$template) {
            $template['price'] = $giftsWithId[$template['gift_id']]['price'];
        }
        return $poolPrizeList;
    }

    public function createNextRoundPrizes(Collection $templatePrizes, $user, int $drawCount)
    {
        // 清空本轮礼物总数
        $this->poolPrizeModel->updateData(['group_id' => $this->group_id], ['template_count' => 0]);
        $this->poolPrizeModel->appendPrizes($this, $templatePrizes);
    }

    public function updatePoolDrawData(array $drawIOPut, int $poolIncrRound, int $drawCount)
    {
        return $this->updateNormalPoolDrawData($this, $drawIOPut, $poolIncrRound, $drawCount);

    }

    public function updateNormalPoolDrawData($poolGroup, array $drawIOPut, int $poolIncrRound, int $drawCount)
    {
        $input                    = $drawIOPut['input'];
        $output                   = $drawIOPut['output'];
        $poolUpdateData           = ['count' => DB::raw('count +' . $drawCount)];
        $poolUpdateData['input']  = DB::raw('input +' . $input);
        $poolUpdateData['output'] = DB::raw('output +' . $output);

        //日数据和周数据的新增处理 为了防止并发已缓存中数据为主 数据库后续更新  缓存的值来做数据判断  数据库值来做统计用

        $inputDate  = $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_DATE_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-m-d"), 'input', $input);
        $outputDate = $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_DATE_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-m-d"), 'output', $output);
        $inputWeek  = $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_WEEK_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-W"), 'input', $input);
        $outputWeek = $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_WEEK_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-W"), 'output', $output);
        $this->redisObject->expire($this->cachePrefix . CacheKey::POOL_DATE_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-m-d"), 48 * 3600);
        $this->redisObject->expire($this->cachePrefix . CacheKey::POOL_WEEK_PUT_RECORD . ":$poolGroup->pool_id" . "_" . date("Y-m-d"), 14 * 24 * 3600);

        app('events')->listen('draw.redisRollback', function () use ($drawIOPut, $poolIncrRound) {
            $this->redisObject->incrBy($this->cachePrefix . CacheKey::POOL_ROUND . ":$this->pool_id", -$poolIncrRound);
            $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_DATE_PUT_RECORD . ":$this->pool_id" . "_" . date("Y-m-d"), 'input', -$drawIOPut['input']);
            $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_DATE_PUT_RECORD . ":$this->pool_id" . "_" . date("Y-m-d"), 'output', -$drawIOPut['output']);
            $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_WEEK_PUT_RECORD . ":$this->pool_id" . "_" . date("Y-W"), 'input', -$drawIOPut['input']);
            $this->redisObject->hincrby($this->cachePrefix . CacheKey::POOL_WEEK_PUT_RECORD . ":$this->pool_id" . "_" . date("Y-W"), 'output', -$drawIOPut['output']);
        });

        if ($poolIncrRound > 0) {
            $round                   = $this->redisObject->incrBy($this->cachePrefix . CacheKey::POOL_ROUND . ":$poolGroup->pool_id", $poolIncrRound);
            $poolUpdateData['round'] = $round;
        }

        $poolUpdateData['input_date']       = $inputDate;
        $poolUpdateData['output_date']      = $outputDate;
        $poolUpdateData['input_week']       = $inputWeek;
        $poolUpdateData['output_week']      = $outputWeek;
        $poolUpdateData['current_group_id'] = $poolGroup->group_id;

        return $poolUpdateData;
    }


    // 追加奖励
    public function appendPrizes(array $prizes, array $append)
    {
        foreach ($append as $groupId => $groupPrize) {
            foreach ($groupPrize as $prizeId => $prizeCount) {
                if (isset($prizes[$groupId][$prizeId])) {
                    $prizes[$groupId][$prizeId] += $prizeCount;
                } else {
                    $prizes[$groupId][$prizeId] = $prizeCount;
                }
            }
        }

        return $prizes;
    }


    public function drawPrizes(Collection $poolPrizeList, $poolConfig, $poolGroup, $user, $drawCount)
    {
        $remainDrawCount = $drawCount;

        $drawPrizes = [];
        if ($drawCount <= 0) {
            return [];
        }
        $poolCount = $poolPrizeList->where('count', '>', 0)->sum('count');

        //奖池礼物不足则全部抽取
        if ($poolCount < $drawCount) {
            //todo 是否要添加补充逻辑
            throw new BasicException(-1, '奖池礼物不充足');
        }

        if ($user->status == 1) {
            //校验是否可以抽取顶级礼物

            if ($this->checkTopPrizeCondition($user, $poolGroup)) {
                $topPrizesRes    = $this->drawTopPrize($poolPrizeList, $poolConfig, $poolGroup, $user, $remainDrawCount);
                $topPrizes       = $topPrizesRes['prizes'];
                $topPrizesCount  = $topPrizesRes['count'];
                $remainDrawCount -= $topPrizesCount;
            }

            //校验是否可以抽取大礼物
            if ($this->checkBigPrizeCondition($user, $poolGroup) && $remainDrawCount > 0) {
                $bigPrizesRes    = $this->drawBigPrize($poolPrizeList, $poolConfig, $poolGroup, $user, $remainDrawCount);
                $bigPrizes       = $bigPrizesRes['prizes'];
                $bigPrizesCount  = $bigPrizesRes['count'];
                $remainDrawCount -= $bigPrizesCount;
            }
        }
        if ($remainDrawCount > 0) {
            $drawPrizes = $this->drawNormalPrize($poolPrizeList, $remainDrawCount, $poolConfig);
        }
        //  中等礼物追加
        if (!empty($topPrizes)) {
            foreach ($topPrizes as $groupId => $topGroupPrize) {
                foreach ($topGroupPrize as $topPrizeId => $topPrizeCount) {
                    if (isset($drawPrizes[$groupId][$topPrizeId])) {
                        $drawPrizes[$groupId][$topPrizeId]['count'] += $topPrizeCount;
                    } else {
                        $drawPrizes[$groupId][$topPrizeId] = $topPrizeCount;
                    }
                }
            }
        }

        if (!empty($bigPrizes)) {
            foreach ($bigPrizes as $groupId => $bigGroupPrize) {
                foreach ($bigGroupPrize as $bigPrizeId => $bigPrizeCount) {
                    if (isset($drawPrizes[$groupId][$bigPrizeId])) {
                        $drawPrizes[$groupId][$bigPrizeId] += $bigPrizeCount;
                    } else {
                        $drawPrizes[$groupId][$bigPrizeId] = $bigPrizeCount;
                    }
                }
            }
        }

        return $drawPrizes;

    }

    public function checkTopPrizeCondition($user, $poolGroup)
    {
        if (!$this->redisObject->setnx($this->cachePrefix . CacheKey::POOL_TOP_PRIZE_LIMIT . "_" . $poolGroup->pool_id, 1)) {
            return false;
        } else {
            $this->redisObject->del($this->cachePrefix . CacheKey::POOL_TOP_PRIZE_LIMIT . "_" . $poolGroup->pool_id);
        }

        $userInputDate = $this->redisObject->hget($this->cachePrefix . CacheKey::USER_DATE_PUT_RECORD . ":$user->user_id" . "_" . date("Y-m-d"), 'input');
        return $userInputDate >= $poolGroup->lucky_input_value_date;
    }

    public function checkBigPrizeCondition($user, $poolGroup)
    {
        if (!$this->redisObject->setnx($this->cachePrefix . CacheKey::POOL_BIG_PRIZE_LIMIT . "_" . $poolGroup->pool_id, 1)) {
            return false;
        } else {
            $this->redisObject->del($this->cachePrefix . CacheKey::POOL_BIG_PRIZE_LIMIT . "_" . $poolGroup->pool_id);
        }
        $userInputDate = $this->redisObject->hget($this->cachePrefix . CacheKey::USER_DATE_PUT_RECORD . ":$user->user_id" . "_" . date("Y-m-d"), 'input');
        return $userInputDate >= $poolGroup->lucky_input_value_date;
    }

    public function drawTopPrize(Collection $poolPrizeList, $poolConfig, $poolGroup, $user, int $drawCount)
    {
        $limitKey  = $this->cachePrefix . CacheKey::POOL_TOP_PRIZE_LIMIT . "_" . $poolGroup->pool_id;
        $topPrizes = $this->poolPedometerDraw($poolPrizeList, $poolConfig->top_gift_coin, 0, $poolGroup->top_count,
            $poolGroup->top_random, $drawCount, $limitKey);

        $poolModel = $this->poolModel;
        $poolId    = $poolGroup->pool_id;

        $topPrizeCount = 0;
        foreach ($topPrizes as $groupPrize) {
            foreach ($groupPrize as $prizeCount) {
                $topPrizeCount += $prizeCount;
            }
        }
        $topPrizesRes = ['prizes' => $topPrizes, 'count' => 0];
        if ($topPrizeCount > 0) {
            //触发事件 计数清零 种子重新随机
            $topSection = json_decode($poolGroup->top_step_section, true);

            app('events')->listen('draw.resetCount', function () use ($poolModel, $poolId, $topSection, $user, $limitKey) {

                $this->redisObject->hset($this->cachePrefix . CacheKey::USER_LAST_BIG_DRAW_COUNT, $user->user_id, 0);
                $poolModel->updateData(['id' => $poolId], ['top_count' => 0, 'top_random' => mt_rand($topSection[0], $topSection[1])]);
                //出奖后去除并发锁
                $this->redisObject->expire($limitKey, 1);
            });
        }
        $topPrizesRes['count'] = $topPrizeCount;
        return $topPrizesRes;
    }

    public function drawBigPrize(Collection $poolPrizeList, $poolConfig, $poolGroup, $user, int $drawCount)
    {
        $limitKey  = $this->cachePrefix . CacheKey::POOL_BIG_PRIZE_LIMIT . "_" . $poolGroup->pool_id;
        $bigPrizes = $this->poolPedometerDraw($poolPrizeList, $poolConfig->big_gift_coin, $poolConfig->top_gift_coin,
            $poolGroup->big_count, $poolGroup->big_random, $drawCount, $limitKey);

        $poolModel = $this->poolModel;
        $poolId    = $poolGroup->pool_id;

        $bigPrizeCount = 0;
        foreach ($bigPrizes as $groupPrize) {
            foreach ($groupPrize as $prizeCount) {
                $bigPrizeCount += $prizeCount;
            }
        }
        $bigPrizesRes = ['prizes' => $bigPrizes, 'count' => 0];
        if ($bigPrizeCount > 0) {
            //触发事件 计数清零 种子重新随机
            $bigSection = json_decode($poolGroup->big_step_section, true);
            app('events')->listen('draw.resetCount', function () use ($poolModel, $poolId, $bigSection, $user, $limitKey) {
                $this->redisObject->hset($this->cachePrefix . CacheKey::USER_LAST_BIG_DRAW_COUNT, $user->user_id, 0);
                $poolModel->updateData(['id' => $poolId], ['big_count' => 0, 'big_random' => mt_rand($bigSection[0], $bigSection[1])]);
                //出奖后去除并发锁
                $this->redisObject->expire($limitKey, 1);
            });
        }
        $bigPrizesRes['count'] = $bigPrizeCount;
        return $bigPrizesRes;
    }

    public function drawNormalPrize(Collection $poolPrizeList, int $count, $poolConfig)
    {

        $normalPool = $poolPrizeList
            ->where('count', '>', 0)
            ->where('price', '<', $poolConfig->big_gift_coin);
        $sumCount   = $normalPool->sum('count');
        $normalPool = $normalPool->toArray();
        if ($sumCount < 1) {
            return [];
        }

        //根据剩余数量进行权重抽取
        $prizeId = 0;
        $groupId = 0;
        //权重总值
        $totalWeight = $sumCount;
        $randomId    = mt_rand(1, $totalWeight);
        $weight      = 0;
        $drawPrizes  = [];
        while ($count) {
            foreach ($normalPool as &$mPool) {
                if ($randomId > $weight && $randomId <= ($mPool['count'] + $weight)) {
                    $prizeId = $mPool['gift_template_id'];
                    $groupId = $mPool['group_id'];
                    $mPool['count']--;
                    $totalWeight--;
                    $weight = 0;
                    break;
                } else {
                    $weight += $mPool['count'];
                }
            }
            if ($totalWeight > 0) {
                $randomId = mt_rand(1, $totalWeight);
            }

            if (isset($drawPrizes[$groupId][$prizeId])) {
                $drawPrizes[$groupId][$prizeId]++;
            } else {
                $drawPrizes[$groupId][$prizeId] = 1;
            }
            $count--;
        }

        return $drawPrizes;
    }

    public function getDrawPrizesCount(array $drawPrizes)
    {
        $drawPrizesCount = 0;
        foreach ($drawPrizes as $groupPrize) {
            foreach ($groupPrize as $prizeCount) {
                $drawPrizesCount += $prizeCount;
            }
        }
        return $drawPrizesCount;
    }

    public function transformDrawPrizes(array $drawPrizes)
    {
        return $drawPrizes;
    }

    public function poolPedometerDraw(Collection $poolPrizeList, int $minPrizeCoin, int $maxPrizeCoin, int $prizeCount, int $prizeRandom, int $drawCount, $redisLimitKey)
    {

        $drawPrizes = $poolPrizeList->where('price', '>=', $minPrizeCoin); // 特殊礼物
        if ($maxPrizeCoin > 0) {
            $drawPrizes = $drawPrizes->where('price', '<', $maxPrizeCoin); // 特殊礼物
        }
        $prizesRemainCount    = $poolPrizeList->where('count', '>', 0)->sum('count'); // 奖品当前剩余数量
        $prizesTotalCount     = $poolPrizeList->sum('template_count'); // 奖品总数(包含被抽的数量
        $drawPrizesCount      = $drawPrizes->where('count', '>', 0)->sum('count'); // 特殊礼物当前数量
        $drawPrizesTotalCount = $drawPrizes->sum('template_count'); // 特殊礼物总数
        if ($drawPrizesCount <= 0) { // 无特殊礼物
            return [];
        }
        $interval        = $prizesTotalCount / $drawPrizesTotalCount; // 礼物间隔 = 奖品总数 / 特殊礼物数量
        $drawEndPosition = $prizesTotalCount - $prizesRemainCount + $drawCount + 1; // 本次抽取结束位置 = 奖品总数 - 奖品剩余数量 + 本次抽取数量 + 1

        $drawPrizesRes = []; // 抽中礼物
//        while ($drawPrizesCount) {
//            $number        = $drawPrizesTotalCount - $drawPrizesCount + 1; // 特殊礼物序号 = 特殊礼物总数 - 特殊礼物数量 + 1
//            $startPosition = $interval * ($number - 1) + 1; // 奖品开始区间 = 间隔 * (序号 - 1) + 1.
//            $endPosition   = $interval * $number; // 奖品结束区间 = 间隔 * 序号
//            $position      = mt_rand($startPosition, $endPosition); // 奖品随机位置
//            // if($position <= $drawEndPosition && $getCount <= $count){ // 奖品位置 < 抽取结束位置 && 抽中数量 <= 抽取数量 为抽中 (改为只抽出一个奖品 后废弃
//            if ($position <= $drawEndPosition) { // 奖品位置 < 抽取结束位置 && 抽中数量 <= 抽取数量 为抽中
        if ($drawCount > 0 && $prizeCount >= $prizeRandom && $this->redisObject->setnx($redisLimitKey, 1)) {
            $drawPrize = $drawPrizes->where('count', '>', 0)->random();

            $this->redisObject->expire($redisLimitKey, 2);
        }

        if (!empty($drawPrize)) {

            if (!isset($drawPrizesRes[$drawPrize->group_id][$drawPrize->gift_template_id])) {
                $drawPrizesRes[$drawPrize->group_id][$drawPrize->gift_template_id] = 1;
            } else {
                $drawPrizesRes[$drawPrize->group_id][$drawPrize->gift_template_id]++;
            }
            $prize        = $drawPrizes->where('gift_template_id', $drawPrize->gift_template_id)->first();
            $prize->count -= 1;
            // $getCount++; (改为只抽出一个奖品 后废弃
//                    break; // 抽中一个跳出循环
        }
//            }
        $drawPrizesCount--;
//        }
        return $drawPrizesRes;
    }


    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $id
     * @return PoolGroup
     */
    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPoolId()
    {
        return $this->pool_id;
    }

    /**
     * @param mixed $pool_id
     * @return PoolGroup
     */
    public function setPoolId($pool_id)
    {
        $this->pool_id = $pool_id;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTag()
    {
        return $this->tag;
    }

    /**
     * @param mixed $tag
     * @return PoolGroup
     */
    public function setTag($tag)
    {
        $this->tag = $tag;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param mixed $name
     * @return PoolGroup
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getRound()
    {
        return $this->round;
    }

    /**
     * @param mixed $round
     * @return PoolGroup
     */
    public function setRound($round)
    {
        $this->round = $round;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCount()
    {
        return $this->count;
    }

    /**
     * @param mixed $count
     * @return PoolGroup
     */
    public function setCount($count)
    {
        $this->count = $count;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCurrentGroupId()
    {
        return $this->current_group_id;
    }

    /**
     * @param mixed $current_group_id
     * @return PoolGroup
     */
    public function setCurrentGroupId($current_group_id)
    {
        $this->current_group_id = $current_group_id;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTopCount()
    {
        return $this->top_count;
    }

    /**
     * @param mixed $top_count
     * @return PoolGroup
     */
    public function setTopCount($top_count)
    {
        $this->top_count = $top_count;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTopRandom()
    {
        return $this->top_random;
    }

    /**
     * @param mixed $top_random
     * @return PoolGroup
     */
    public function setTopRandom($top_random)
    {
        $this->top_random = $top_random;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getBigCount()
    {
        return $this->big_count;
    }

    /**
     * @param mixed $big_count
     * @return PoolGroup
     */
    public function setBigCount($big_count)
    {
        $this->big_count = $big_count;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getBigRandom()
    {
        return $this->big_random;
    }

    /**
     * @param mixed $big_random
     * @return PoolGroup
     */
    public function setBigRandom($big_random)
    {
        $this->big_random = $big_random;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTopStepSection()
    {
        return $this->top_step_section;
    }

    /**
     * @param mixed $top_step_section
     * @return PoolGroup
     */
    public function setTopStepSection($top_step_section)
    {
        $this->top_step_section = $top_step_section;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getBigStepSection()
    {
        return $this->big_step_section;
    }

    /**
     * @param mixed $big_step_section
     * @return PoolGroup
     */
    public function setBigStepSection($big_step_section)
    {
        $this->big_step_section = $big_step_section;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getLuckyInputValueDate()
    {
        return $this->lucky_input_value_date;
    }

    /**
     * @param mixed $lucky_input_value_date
     * @return PoolGroup
     */
    public function setLuckyInputValueDate($lucky_input_value_date)
    {
        $this->lucky_input_value_date = $lucky_input_value_date;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getGroupId()
    {
        return $this->group_id;
    }

    /**
     * @param mixed $group_id
     * @return PoolGroup
     */
    public function setGroupId($group_id)
    {
        $this->group_id = $group_id;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPoolModel()
    {
        return $this->poolModel;
    }

    /**
     * @param mixed $poolModel
     * @return PoolGroup
     */
    public function setPoolModel($poolModel)
    {
        $this->poolModel = $poolModel;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPoolGroupModel()
    {
        return $this->poolGroupModel;
    }

    /**
     * @param mixed $poolGroupModel
     * @return PoolGroup
     */
    public function setPoolGroupModel($poolGroupModel)
    {
        $this->poolGroupModel = $poolGroupModel;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPoolPrizeModel()
    {
        return $this->poolPrizeModel;
    }

    /**
     * @param mixed $poolPrizeModel
     * @return PoolGroup
     */
    public function setPoolPrizeModel($poolPrizeModel)
    {
        $this->poolPrizeModel = $poolPrizeModel;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getRedisObject()
    {
        return $this->redisObject;
    }

    /**
     * @param mixed $redisObject
     * @return PoolGroup
     */
    public function setRedisObject($redisObject)
    {
        $this->redisObject = $redisObject;
        return $this;
    }

}
